package com.fan.controller;

import com.fan.entity.Report;
import com.fan.service.ReportService;
import com.fan.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class ReportController {

    @Autowired
    private ReportService reportService;

    @PostMapping("/report")
    public AjaxResult newReport(int userId, int articleId,
                                int reportedId, String content, String img){

        Report report = new Report();
        report.setUserId(userId);
        report.setArticleId(articleId);
        report.setReportedId(reportedId);
        report.setContent(content);
        report.setImg(img);
        report.setTime(new Date());

        int i = reportService.newReport(report);
        return AjaxResult.success("举报成功",i);
    }
}
